<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get result of next query when executing multiple SQL statements</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.cubrid-move-cursor.html">« cubrid_move_cursor</a></li>
      <li style="float: right;"><a href="function.cubrid-num-cols.html">cubrid_num_cols »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.cubrid.html">CUBRID 函数</a></li>
    <li>Get result of next query when executing multiple SQL statements</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.cubrid-next-result" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">cubrid_next_result</h1>
  <p class="verinfo">(PECL CUBRID &gt;= 8.4.0)</p><p class="refpurpose"><span class="refname">cubrid_next_result</span> &mdash; <span class="dc-title">Get result of next query when executing multiple SQL statements</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.cubrid-next-result-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>cubrid_next_result</strong></span>(<span class="methodparam"><span class="type">resource</span> <code class="parameter">$result</code></span>): <span class="type">bool</span></div>

  <p class="para rdfs-comment">
    The <span class="function"><strong>cubrid_next_result()</strong></span> function is used to get
    results of next query if multiple SQL statements are executed and
   <strong><code>CUBRID_EXEC_QUERY_ALL</code></strong> flag is set upon
    <span class="function"><a href="function.cubrid-execute.html" class="function">cubrid_execute()</a></span>.
   </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.cubrid-next-result-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
  <dl>
    
  <dt>
<code class="parameter">result</code></dt>

  <dd>
<p class="para"><code class="parameter">result</code> comes from a call to <span class="function"><a href="function.cubrid-execute.html" class="function">cubrid_execute()</a></span></p></dd>

   
  </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.cubrid-next-result-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.cubrid-next-result-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-1164">
   <p><strong>示例 #1 <span class="function"><strong>cubrid_next_result()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"127.0.0.1"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">33000</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"demodb"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"dba"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$sql_stmt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"SELECT&nbsp;*&nbsp;FROM&nbsp;code;&nbsp;SELECT&nbsp;*&nbsp;FROM&nbsp;history&nbsp;WHERE&nbsp;host_year=2004&nbsp;AND&nbsp;event_code=20281"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$res&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$conn</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sql_stmt</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CUBRID_EXEC_QUERY_ALL</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">get_result_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">cubrid_next_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">get_result_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">);<br /><br />function&nbsp;</span><span style="color: #0000BB">get_result_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">)<br />{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"\n------------&nbsp;get_result_info&nbsp;--------------------\n"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$row_num&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_num_rows</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$col_num&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_num_cols</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$column_name_list&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_column_names</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$column_type_list&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_column_types</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$column_last_name&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_field_name</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$col_num&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$column_last_table&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_field_table</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$col_num&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$column_last_type&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_field_type</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$col_num&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$column_last_len&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_field_len</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$col_num&nbsp;</span><span style="color: #007700">-&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$column_1_flags&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_field_flags</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%-30s&nbsp;%d\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Row&nbsp;count:"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$row_num</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%-30s&nbsp;%d\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Column&nbsp;count:"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$col_num</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%-30s&nbsp;%-30s&nbsp;%-15s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Column&nbsp;Names"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Column&nbsp;Types"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Column&nbsp;Len"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"------------------------------------------------------------------------------\n"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$size&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">count</span><span style="color: #007700">(</span><span style="color: #0000BB">$column_name_list</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;for(</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">$size</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$column_len&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">cubrid_field_len</span><span style="color: #007700">(</span><span style="color: #0000BB">$req</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%-30s&nbsp;%-30s&nbsp;%-15s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$column_name_list</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">],&nbsp;</span><span style="color: #0000BB">$column_type_list</span><span style="color: #007700">[</span><span style="color: #0000BB">$i</span><span style="color: #007700">],&nbsp;</span><span style="color: #0000BB">$column_len</span><span style="color: #007700">);&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"\n\n"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%-30s&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Last&nbsp;Column&nbsp;Name:"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$column_last_name</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%-30s&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Last&nbsp;Column&nbsp;Table:"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$column_last_table</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%-30s&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Last&nbsp;Column&nbsp;Type:"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$column_last_type</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%-30s&nbsp;%d\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Last&nbsp;Column&nbsp;Len:"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$column_last_len</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%-30s&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Second&nbsp;Column&nbsp;Flags:"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$column_1_flags</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"\n\n"</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
------------ get_result_info --------------------
Row count:                     6
Column count:                  2

Column Names                   Column Types                   Column Len     
------------------------------------------------------------------------------
s_name                         char                           1              
f_name                         varchar                        6              


Last Column Name:              f_name
Last Column Table:             code
Last Column Type:              varchar
Last Column Len:               6
Second Column Flags:           



------------ get_result_info --------------------
Row count:                     4
Column count:                  5

Column Names                   Column Types                   Column Len     
------------------------------------------------------------------------------
event_code                     integer                        11             
athlete                        varchar                        40             
host_year                      integer                        11             
score                          varchar                        10             
unit                           varchar                        5              


Last Column Name:              unit
Last Column Table:             history
Last Column Type:              varchar
Last Column Len:               5
Second Column Flags:           not_null primary_key unique_key
</pre></div>
   </div>
  </div>
 </div>


    <div class="refsect1 seealso" id="refsect1-function.cubrid-next-result-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.cubrid-execute.html" class="function" rel="rdfs-seeAlso">cubrid_execute()</a> - Execute a prepared SQL statement</span></li>
   </ul>
  </p>
  </div>


</div></div></div></body></html>